<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>更新员工信息</title>
</head>
<body>
<h3>更新员工 ${emp.lastName} 信息</h3>
<form action="/restCrud/emp/" method="post">
    <input type="hidden" value="PUT" name="_method">
    <input type="hidden" value="${emp.id}" name="id">
    <%--<input type="hidden" value="${emp.lastName}" name="lastName"/>--%>
    LastName: <span>${emp.lastName}</span>
    <br><br>
    Gender:
    <c:choose>
        <c:when test="${emp.gender == 'M'}">
            <input type="radio" name="gender" value="M" checked="checked"/>男 <input type="radio" name="gender"
                                                                                    value="W"/>女
        </c:when>
        <c:otherwise>
            <input type="radio" name="gender" value="M"/>男 <input type="radio" name="gender" value="W"
                                                                  checked="checked"/>女
        </c:otherwise>
    </c:choose>
    <br><br>
    Email: <input type="text" value="${emp.email}" name="email">
    <br><br>
    Department:
    <select name="department.id">
        <c:if test="${empty departments}">
            <option value="null">暂无部门可选</option>
        </c:if>
        <c:if test="${!empty departments}">
            <c:forEach items="${departments}" var="department">
                <c:choose>
                    <c:when test="${emp.department.departName == department.departName}">
                        <option value="${department.id}" selected="selected">${department.departName}</option>
                    </c:when>
                    <c:otherwise>
                        <option value="${department.id}">${department.departName}</option>
                    </c:otherwise>
                </c:choose>
            </c:forEach>
        </c:if>
    </select>
    <br><br>
    <input type="submit" value="确定更改"/>
</form>
</body>
</html>
